package com.sh_rw.label.common.parser;

import com.sh_rw.label.bean.RFBean;
import com.sh_rw.label.listener.ParserListener;
import com.sh_rw.label.utils.HexUtils;

/**
 * 射频参数解析器
 * Created by rw-duke on 2018/4/8.
 */

public class _RFParser extends Parser {

    private RFBean rfBean;

    @Override
    public void onLabelParser(byte[] data, ParserListener listener) {
//        02030405001B71B8FD431001000113012564000102030405060700
//        super.onLabelParser(data, listener);
//        if (isIntercept) {
            rfBean = new RFBean();
            rfBean.head = HexUtils.toHexString(data[0], data[1], data[2], data[3]);
            rfBean.length = HexUtils.toHexString(data[4], data[5]);
            rfBean.devId = HexUtils.toHexString(data[6], data[7], data[8], data[9]);
            rfBean.cmd = HexUtils.toHexString(data[10]);
            rfBean.sn = HexUtils.toHexString(data[11]);
            rfBean.encryption = HexUtils.toHexString(data[12]);
            rfBean.setRf_Id(HexUtils.toHexString(data[13]));
            rfBean.setLabel_type(HexUtils.toHexString(data[14]));
            rfBean.setSpeed(HexUtils.toHexString(data[15]));
            rfBean.setChannel(HexUtils.toHexString(data[16]));
            rfBean.setRange(HexUtils.toHexString(data[17]));
            rfBean.setRev1(HexUtils.toHexString(data[18]));
            rfBean.setRev2(HexUtils.toHexString(data[19]));
            rfBean.setRev3(HexUtils.toHexString(data[20]));
            rfBean.setRev4(HexUtils.toHexString(data[21]));
            rfBean.setRev5(HexUtils.toHexString(data[22]));
            rfBean.setRev6(HexUtils.toHexString(data[23]));
            rfBean.setRev7(HexUtils.toHexString(data[24]));
            rfBean.setRev8(HexUtils.toHexString(data[25]));
            rfBean.checkSum = HexUtils.toHexString(data[26]);

            listener.onRFCallback(rfBean);
//        }
    }

    @Override
    public boolean check(byte[] data) {
        return true;
    }
}
